import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class HihoCoder1040 {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int num = in.nextInt();

		while(num-->0){
			Set<String> set = new HashSet<String>();
			int[] vx = new int[4];
			int[] vy = new int[4];
			for (int j = 0; j < 4; j++) {
				int x1 = in.nextInt();
				int y1 = in.nextInt();
				int x2 = in.nextInt();
				int y2 = in.nextInt();
				set.add(x1 + "-" + y1);
				set.add(x2 + "-" + y2);
				vx[j] = x2 - x1;
				vy[j] = y2 - y1;
			}
			if (set.size() != 4) {
				System.out.println("NO");
				continue;
			}

			boolean valid = true;
			for (int i = 1; i < 4; i++) {
				if (!(vx[0] * vx[i] + vy[0] * vy[i] == 0 || vx[0] * vy[i] - vy[0] * vx[i] == 0)) {
					valid = false;
					break;
				}
			}
			
			  if (valid) {  
	                System.out.println("YES");  
	            } else {  
	                System.out.println("NO");  
	            }  

		}

	}

}
